package com.example.skycode7.dao;

import com.example.skycode7.utill.DBConnection;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class AdminDao {
    DBConnection DBConn = new DBConnection();
    public boolean CheckLogin(String s1,String s2) throws SQLException {
        Connection conn=DBConn.getConn();//获取Mysql链接
        Statement statement=conn.createStatement();// 获取处理对象
        ResultSet rs=null;//声明结果集对象
        boolean OK=true;
        String sql="select * from admin where Adminname = '"+s1+"'and AdminPwd ='"
                +s2+"'";//查询账号密码语句
        rs = statement.executeQuery(sql);//执行sql查询
        if (!rs.next()){//如果没查询出数据 没有该用户
            OK = false;
        }else {
            OK = true;//表示有该用户
            //todo 后期需要添加账户密码严格验证
        }
        return OK;
    }
}
